package com.frossini.proyectologin.adapter;

import java.text.SimpleDateFormat;

import com.frossini.proyectologin.R;
import com.frossini.proyectologin.model.Cliente;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ClientesAdapter extends ArrayAdapter<Cliente>
{
	private class ViewHolder
	{
		TextView tv_id_cliente;
		TextView tv_tli_descripcion;
		
	}
	
	public ClientesAdapter(Context context){
		super(context,-1);
	
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		Cliente cliente = getItem(position); 
		ViewHolder viewHolder;
		
		if (convertView ==null)
		{
			LayoutInflater inflater = LayoutInflater.from(getContext());
			convertView = inflater.inflate(R.layout.cliente_list_item,parent,false);
			viewHolder = new ViewHolder();
			viewHolder.tv_id_cliente = (TextView) convertView.findViewById(R.id.tv_id_cliente);
			viewHolder.tv_tli_descripcion = (TextView) convertView.findViewById(R.id.tv_tli_descripcion);
			convertView.setTag(viewHolder);
		}
		else
		{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.tv_id_cliente.setText(String.valueOf(cliente.getIdCliente()));
		viewHolder.tv_tli_descripcion.setText(cliente.getNombre());
		return convertView;
	}
	

}
